package com.techfansy.photo;

import android.app.Activity;
import android.content.Intent;

/**
 * Created by Administrator on 2018/4/2/002.
 */

public class PhotoSelect {
    public final static int REQUEST_CAMERA = 0X0015;
    private PhotoSelect photoSelect;
    private boolean isImageCrop = false;
    private boolean isPicture = true;

    private Activity activity;

    /**
     * @param isPicture   是否选择图片  默认是true选择图库
     * @param isImageCrop 是否裁剪  默认是false不裁剪
     * @param activity
     */
    public PhotoSelect(Activity activity, boolean isPicture, boolean isImageCrop) {

        this.isPicture = isPicture;
        this.isImageCrop = isImageCrop;
        this.activity = activity;
        setIntent(activity);
    }

    /**
     * @param isPicture 是否是图片  默认是true
     * @param activity
     */
    public PhotoSelect(boolean isPicture, Activity activity) {
        this.isPicture = isPicture;
        this.activity = activity;
        setIntent(activity);
    }

    /**
     * @param isImageCrop 是否剪切图片 默认是false
     * @param activity
     */
    public PhotoSelect(Activity activity, boolean isImageCrop) {
        this.isImageCrop = isImageCrop;
        this.activity = activity;
        setIntent(activity);
    }

    /**
     * @param activity
     */
    public PhotoSelect(Activity activity) {
        this.activity = activity;
        setIntent(activity);
    }

    private void setIntent(Activity activity) {
        Intent intent = new Intent(activity, ImageCropActivity.class);
        if (isImageCrop) {
            intent.putExtra("isCrop", isImageCrop);
        }
        intent.putExtra("isPicture", isPicture);
        activity.startActivityForResult(intent, REQUEST_CAMERA);
    }
}
